/*
MySQL Backup
Database: shopping_db
Backup Time: 2025-07-01 11:41:21
*/

SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `shopping_db`.`cart`;
DROP TABLE IF EXISTS `shopping_db`.`order_item`;
DROP TABLE IF EXISTS `shopping_db`.`orders`;
DROP TABLE IF EXISTS `shopping_db`.`product`;
DROP TABLE IF EXISTS `shopping_db`.`user`;
CREATE TABLE `cart` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `product_id` int NOT NULL,
  `quantity` int DEFAULT '1',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `cart_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
  CONSTRAINT `cart_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_zh_0900_as_cs;
CREATE TABLE `order_item` (
  `id` int NOT NULL AUTO_INCREMENT,
  `order_id` int NOT NULL,
  `product_id` int NOT NULL,
  `quantity` int NOT NULL,
  `price` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `product_id` (`product_id`),
  CONSTRAINT `order_item_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`),
  CONSTRAINT `order_item_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_zh_0900_as_cs;
CREATE TABLE `orders` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `total_amount` decimal(10,2) NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_zh_0900_as_cs DEFAULT '待支付',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `receiver_name` varchar(50) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `receiver_address` varchar(200) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `receiver_phone` varchar(20) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `paid_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_zh_0900_as_cs;
CREATE TABLE `product` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `name` varchar(100) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `description` text COLLATE utf8mb4_zh_0900_as_cs,
  `price` decimal(10,2) NOT NULL,
  `category` varchar(50) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `image_path` varchar(255) COLLATE utf8mb4_zh_0900_as_cs DEFAULT NULL,
  `status` tinyint DEFAULT '1' COMMENT '1-上架, 0-下架',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `product_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_zh_0900_as_cs;
CREATE TABLE `user` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `password` varchar(100) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `email` varchar(100) COLLATE utf8mb4_zh_0900_as_cs NOT NULL,
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_zh_0900_as_cs;
BEGIN;
LOCK TABLES `shopping_db`.`cart` WRITE;
DELETE FROM `shopping_db`.`cart`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `shopping_db`.`order_item` WRITE;
DELETE FROM `shopping_db`.`order_item`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `shopping_db`.`orders` WRITE;
DELETE FROM `shopping_db`.`orders`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `shopping_db`.`product` WRITE;
DELETE FROM `shopping_db`.`product`;
INSERT INTO `shopping_db`.`product` (`id`,`user_id`,`name`,`description`,`price`,`category`,`image_path`,`status`,`created_time`) VALUES (1, 1, '黄鹏鑫', '小丑一个', 11.20, '服装', '/resources/uploads/ffe4c04e-f0ff-4c44-b2be-c8ee00a00e2d_b_d3a388de6f2a29db0e3e63c9c93cfd8b.jpg', 1, '2025-06-14 15:02:37'),(2, 1, '你的404', 'Day Day All Bug~~~', 99.60, '运动', '/resources/uploads/8a436025-02b8-44ae-a6d4-24427e5060db_盒子娘.png', 1, '2025-06-14 15:14:13'),(3, 3, '就你叫柴郡', '阿巴吧吧。。。。。。。。。。。\r\n阿巴吧吧。。。。。。。。。。。\r\n阿巴吧吧。。。。。。。。。。。', 124.20, '图书', '/resources/uploads/6c1f1ea1-7621-4c92-aa80-90d012fa4b14_柴郡.jpg', 1, '2025-06-16 09:40:15'),(5, 3, '厉不厉害你芙', '厉不厉害你芙\r\n厉不厉害你芙\r\n厉不厉害你芙\r\n厉不厉害你芙\r\n厉不厉害你芙', 9999.99, '母婴', '/resources/uploads/d51ca9c4-7b81-4edd-bd7b-a1855e5046ed_66666666666.png', 1, '2025-06-16 09:43:05'),(6, 3, '同人书签', '忍痛割爱，便宜你们了', 520.00, '图书', '/resources/uploads/b17275da-0f25-4021-9174-664acf1781ef_6.jpg', 1, '2025-06-16 09:45:39'),(7, 1, '10086', '666', 99.90, '家具', '/resources/uploads/fdb4b54b-5af7-43d5-92d6-e9133f3e19f0_彩蛋.png', 1, '2025-06-17 15:58:03')
;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `shopping_db`.`user` WRITE;
DELETE FROM `shopping_db`.`user`;
INSERT INTO `shopping_db`.`user` (`id`,`username`,`password`,`email`,`created_time`) VALUES (1, 'hpxaaa', '$2a$10$PDGm98tOlQ4Ltw9KF9PtueMSio.8PlGP/D5/e9EOAXTCbn2ttrYQ.', '666@qq.com', '2025-06-14 14:45:26'),(2, 'gyg', '$2a$10$lsiXgrYtmq0ALrBKdaxkiuOHwbwGY2Eh7TRoNq.MtnjSNAHhK1gGq', '123@qq.com', '2025-06-14 21:52:21'),(3, 'gq', '$2a$10$Nt6t.xe6fBgl.3y5nmKTOu1oWG7D1wiBOmzj1uRtbZNIXnuOv3sI2', '666@qq.com', '2025-06-16 09:39:52'),(4, 'fea', '$2a$10$8W5YSH2NJfB50cWW82THFuH4CyMd7Fe4xdzx5yscPi//rIGIsX6sm', '222@qq.com', '2025-06-17 15:55:32')
;
UNLOCK TABLES;
COMMIT;
